package edu.sctu.renpingan.day20150518;



/**
 * Created by user18 on 2015/5/19.
 */
public class TextMore {

    Teacher[] teaCher;

    public TextMore(Teacher[] teaCher) {
        this.teaCher = teaCher;
    }

    public Teacher[] sotrNumber(){
        Teacher[] teacher5 = new Teacher[2];
        for (int j = 0; j < teaCher.length-1; j++) {
            for (int i = 0; i < teaCher.length-1; i++) {
                if (teaCher[i].number>teaCher[i+1].number) {
                    teacher5[i] = teaCher[i+1];
                    teaCher[i+1] = teaCher[i];
                    teaCher[i] = teacher5[i];
                    System.out.println("老师排序后的信息：");
                }
            }
        }
        return this.teaCher;
    }

    public Student[] sortStudent(){

        System.out.println("学生成绩排序前：");
        Student[] studentA = new Student[teaCher.length];


        System.out.println(teaCher[0].student[0].grade+" "+teaCher[0].student[1].grade+"  "+teaCher[0].student[2].grade);

        for(int i =0;i<teaCher[0].student.length;i++){
            for(int j =0;j<teaCher[0].student.length-1-i;j++){
                if(teaCher[0].student[j].grade > teaCher[0].student[j+1].grade){

                    studentA[0] = teaCher[0].student[j];
                    teaCher[0].student[j] = teaCher[0].student[j+1];
                    teaCher[0].student[j+1] = studentA[0];



                    System.out.println("姓名："+teaCher[0].student[j].name+"\t成绩："+teaCher[0].student[j].grade);

                }else {
                    System.out.printf("这里不满足ture   ");

                }
            }
        }
                    System.out.println("排序后"+teaCher[0].student[0].grade+" "+teaCher[0].student[1].grade+"  "+teaCher[0].student[2].grade);
                    return teaCher[0].student;
    }





    public  Teacher[] pritCoded(){


        Teacher[] teacher1 = new Teacher[teaCher.length];

        for (int i = 0; i <teaCher.length ; i++) {
            if (teaCher[i].work.equals("教授")) {
               teacher1[i] = teaCher[i];
            }
        }
        System.out.println("z职称为教授："+teacher1[0].name);
        return teacher1;

    }

}
